package com.cc.service.impl;

import com.cc.entity.Employees;
import com.cc.entity.Suppliers;
import com.cc.entity.SuppliersList;
import com.cc.service.SuppliersService;
import com.cc.mapper.SuppliersMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author hct
 * @description 针对表【suppliers】的数据库操作Service实现
 * @createDate 2024-10-21 09:11:52
 */
@Service
public class SuppliersServiceImpl implements SuppliersService {

    @Autowired
    SuppliersMapper suppliersMapper;

    @Override
    public Suppliers queryById(Integer supplierId) {
        return suppliersMapper.queryById(supplierId);
    }

    /**
     * 分页查询
     *
     * @param suppliers 筛选条件
     * @param pageNum   分页对象
     * @return 查询结果
     */
    @Override
    public PageInfo<Suppliers> queryByPage(Suppliers suppliers, Integer pageNum) {
        PageHelper.startPage(pageNum, 5);
        List<Suppliers> list = suppliersMapper.queryAllByLimit(suppliers, pageNum);
        PageInfo<Suppliers> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    /**
     * 新增数据
     *
     * @param suppliers 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(Suppliers suppliers) {
        return suppliersMapper.insert(suppliers);
    }

    /**
     * 修改数据
     *
     * @param suppliers 实例对象
     * @return 实例对象
     */
    @Override
    public int update(Suppliers suppliers) {
        return suppliersMapper.update(suppliers);
    }

    /**
     * 通过主键删除数据
     *
     * @param supplierId 主键
     * @return 是否成功
     */
    @Override
    public int deleteById(Integer supplierId) {
        return suppliersMapper.deleteById(supplierId);
    }

    @Override
    public List<SuppliersList> queryAll() {
        return suppliersMapper.queryAll();
    }

}




